package com.bwie.controller;

import com.bwie.pojo.TbAtta;
import com.bwie.pojo.TbProd;
import com.bwie.service.TbApprService;
import com.bwie.service.TbProdService;
import com.bwie.service.TbTagService;
import com.bwie.service.TbUnitService;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * @projectName: server-2211a-shop
 * @package: com.bwie
 * @className: ProdController
 * @author: 杨珂
 * @description: TODO
 * @date: 2025/5/26 16:53
 * @version: 1.0
 */
@RestController
@RequestMapping("/shop/prod")
public class ProdController {

    @Autowired
    TbProdService tbProdService;

    @Autowired
    TbUnitService tbUnitService;

    @Autowired
    TbTagService tbTagService;
    @Autowired
    TbApprService tbApprService;

    /**
     * @param pageInfoVo:
     * @return Result
     * @author :杨珂
     * @description 自定义分页列表
     * @date 2025/5/27 20:16
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody PageInfoVo pageInfoVo) {
        return tbProdService.getProdList(pageInfoVo);
    }


    /**
     * @param tbProd:
     * @return Result
     * @author :杨珂
     * @description 添加商品
     * @date 2025/5/27 10:19
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody TbProd tbProd) {
        return tbProdService.addProd(tbProd);
    }

    /**
     * @param :
     * @return Result
     * @author :杨珂
     * @description 查询所有单位
     * @date 2025/5/27 11:13
     */
    @PostMapping("/getUnitListAll")
    public Result getUnitListAll() {
        return tbUnitService.getUnitListAll();
    }

    /**
     * @param :
     * @return Result
     * @author :杨珂
     * @description 查询所有标签
     * @date 2025/5/27 11:13
     */
    @PostMapping("/getTagListAll")
    public Result getTagListAll() {
        return tbTagService.getTagListAll();
    }

    /**
     * @param :
     * @return Result
     * @author :杨珂
     * @description 查询所有供应商
     * @date 2025/5/27 11:13
     */
    @PostMapping("/getApprListAll")
    public Result getApprListAll() {
        return tbApprService.getApprListAll();
    }

    @PostMapping("/deleteAll")
    public Result deleteAll(@RequestBody List<TbProd> prodList) {
        return tbProdService.deleteAll(prodList);
    }


    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody TbAtta tbAtta) {
        return tbProdService.addProdAtta(tbAtta);
    }


    @PostMapping("/checkProd")
    public Result checkProd(@RequestBody TbProd tbProd) {
        return tbProdService.checkProd(tbProd);
    }


    /**
     * @param prodPageVo:
     * @return Result
     * @author :杨珂
     * @description 从Es中获取商品信息列表
     * @date 2025/6/6 14:14
     */
    @PostMapping("/getProdListEs")
    public Result getProdListEs(@RequestBody ProdPageVo prodPageVo) {
        return tbProdService.getProdListEs(prodPageVo);
    }


}
